package what.basic.chooser;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Jcolorchooser {
	Jcolorchooser(){
		JFrame f=new JFrame("jcolorchooser");
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		MYPANEL p=new MYPANEL();
		f.getContentPane().add(p);
		f.pack();
		f.setVisible(true);
	}
	public static void main(String[] args) {
	new Jcolorchooser();	
	}
}
class MYPANEL extends JPanel implements ActionListener{
	private JButton button,rgb,red,green,blue;
	private Color color=new Color(0,0,0);
	public MYPANEL(){
		button =new JButton("Get Color");
		rgb=new JButton("RGB:");
		red=new JButton("Red:");
		green=new JButton("Green:");
		blue=new JButton("Blue;");
		button.addActionListener(this);
		setPreferredSize(new Dimension(550,250));
		setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
		setBackground(color);
		add(button);
		add(rgb);
		add(red);
		add(green);
		add(blue);
	
	}public void actionPerformed(ActionEvent e) {
		color=JColorChooser.showDialog(this, "Choose Color", color);
		setBackground(color);
		button.setText("Get again");
		rgb.setText("RGB:"+color.getRGB());
		red.setText("Red:"+color.getRed());
		green.setText("Green:"+color.getGreen());
		blue.setText("Blue:"+color.getBlue());
	}
}
